package com.lanou.musicproject.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.lanou.musicproject.fragment.MusicFragment;
import com.lanou.musicproject.fragment.MvFragment;
import com.lanou.musicproject.fragment.RankFragment;
import com.lanou.musicproject.fragment.SongListFragment;
import java.util.ArrayList;


/**
 * Created by dllo on 15/10/27.
 */
public class HomePageAdapter extends FragmentPagerAdapter {

    private String [] titles ={"歌手","排行榜","歌单","MV"};

    private ArrayList<Fragment> datas;

    public HomePageAdapter(FragmentManager fm) {
        super(fm);
        init();

    }

    private void init() {
        datas = new ArrayList<>() ;
        datas.add(new MusicFragment());
        datas.add(new RankFragment());
        datas.add(new SongListFragment());
        datas.add(new MvFragment());
        notifyDataSetChanged();

    }

    @Override
    public Fragment getItem(int position) {
        return datas.get(position);
    }

    @Override
    public int getCount() {
        return titles.length;
    }

    public CharSequence getPageTitle(int position) {
        return titles[position];
    }
}
